﻿using System.Collections.Generic;
using System.Web.Mvc;
using LangMauViet.Models.Entity;
using LangMauViet.Models.Service;

namespace LangMauViet.Controllers
{
    public class VideoController : Controller
    {
        //
        // GET: /Video/

        public ActionResult Index()
        {
           

            return View();
        }

        public ActionResult DetailVideo(long id)
        {
            CategoryService s1 = new CategoryService();
            //List<Category> pListCate = s1.GetCategory(0);
            VideoService s = new VideoService();
            List<Video> vlistHot = s.GetVideo(0, 1, 0, 3); //1: download
            List<Video> vlistNew = s.GetVideo(0, 0, 0, 3); //0: moi nhat

            ImageService iser = new ImageService();
            List<Images> lImage = iser.GetImages(0, 0, 0, 3);
            NewsService nser = new NewsService();
            List<News> lNews = nser.GetNews(0, 0, 0, 3);
            ViewData["listVideoHost"] = vlistHot;
            ViewData["listVideoNew"] = vlistNew;
            ViewData["listImage"] = lImage;
            ViewData["listNews"] = lNews;

            VideoService vs = new VideoService();
            Video video = vs.GetDetailVideo(id);
            List<Video> vlist = vs.GetVideo(video.CategoryId, 0, 0, 5);
            CategoryService cs = new CategoryService();
            List<HotItem> lhot = cs.GetHotItem(9);
            vlist.Remove(video);
            ViewData["DetailVideo"] = video;
            ViewData["VideoCouldYouLike"] = vlist;
            ViewData["hotVideo"] = lhot;


            //WEB
            List<Video> lVideoHotWeb = vs.GetVideo(0, 1, 0, 23);
            ViewData["lVideoHotWeb"] = lVideoHotWeb;
            List<Video> nlistHotWeb = vs.GetVideo(0, 0, 0, 24);

            ViewData["nlistHotWeb"] = nlistHotWeb;

            return View(video);
        }

        public ActionResult WatchVideo(long id)
        {
            VideoService vs = new VideoService();
            Video video = vs.GetDetailVideo(id);
            CategoryService cs = new CategoryService();
            List<HotItem> lhot = cs.GetHotItem(9);
            ViewData["WatchVideo"] = video;
            ViewData["hotVideo"] = lhot;
            return View(video);
        }

    }
}
